/**
  ******************************************************************************
  * @file    bs32f1xx_ll_cortex.c
  * @author  MCU Application Team
  * @brief   CORTEX LL module driver.
  ******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "bs32f1xx_ll_cortex.h"

#ifdef  USE_FULL_ASSERT
#include "bs32_assert.h"
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
/** @addtogroup BS32F1xx_LL_Driver
  * @{
  */

/** @addtogroup CORTEX_LL CORTEX
  * @{
  */ 

/* Exported functions --------------------------------------------------------*/
/** @addtogroup CORTEX_LL_Exported_Functions
  * @{
  */

/**
  * @brief  Sets the priority grouping field (preemption priority and subpriority)
  *         using the required unlock sequence.
  * @param  PriorityGroup The priority grouping bits length. 
  *         This parameter can be one of the following values:
  *         @arg LL_NVIC_PRIORITYGROUP_PRE0_SUB4: 0 bits for preemption priority
  *                                    						4 bits for subpriority
  *         @arg LL_NVIC_PRIORITYGROUP_PRE1_SUB3: 1 bits for preemption priority
  *                                    						3 bits for subpriority
  *         @arg LL_NVIC_PRIORITYGROUP_PRE2_SUB2: 2 bits for preemption priority
  *                                    						2 bits for subpriority
  *         @arg LL_NVIC_PRIORITYGROUP_PRE3_SUB1: 3 bits for preemption priority
  *                                    						1 bits for subpriority
  *         @arg LL_NVIC_PRIORITYGROUP_PRE4_SUB0: 4 bits for preemption priority
  *                                    						0 bits for subpriority
  * @note   When the LL_NVIC_PRIORITYGROUP_PRE0_SUB4 is selected, IRQ preemption is no more possible. 
  *         The pending IRQ priority will be managed only by the subpriority. 
  * @retval None
  */
void LL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
{
  /* Check the parameters */
  assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup));
  
  /* Set the PRIGROUP[10:8] bits according to the PriorityGroup parameter value */
  NVIC_SetPriorityGrouping(PriorityGroup);
}

/**
  * @brief  Sets the priority of an interrupt.
  * @param  IRQn External interrupt number.
  *         This parameter can be an enumerator of IRQn_Type enumeration
  * @param  PreemptPriority The preemption priority for the IRQn channel.
  *         This parameter can be a value between 0 and 15
  *         A lower priority value indicates a higher priority 
  * @param  SubPriority the subpriority level for the IRQ channel.
  *         This parameter can be a value between 0 and 15
  *         A lower priority value indicates a higher priority.          
  * @retval None
  */
void LL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
{ 
  uint32_t prioritygroup = 0x00U;
  
  /* Check the parameters */
  assert_param(IS_NVIC_SUB_PRIORITY(SubPriority));
  assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority));
  
  prioritygroup = NVIC_GetPriorityGrouping();
  
  NVIC_SetPriority(IRQn, NVIC_EncodePriority(prioritygroup, PreemptPriority, SubPriority));
}

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */
 
/************************ (C) COPYRIGHT BSMicroelectronics *****END OF FILE****/
